<!--
 * @Descripttion: 课堂分析详情-其他内容-课堂内容概要
 * @version: V1.0.0.1
 * @Author: zhaozhenzhuo
 * @Date: 2025-10-30 15:25:25
 * @LastEditors: zhaozhenzhuo
 * @LastEditTime: 2025-10-30 15:25:25
-->
<template>
	<div class="teaching-content-wrapper">
		<div class="module-title-wrapper">
			<p>课堂内容概要</p>
			<img v-if="false" src="@/assets/images/lessonAnalysisDetails/text-edit-normal.png" />
		</div>
		<div class="detail">
			<p v-html="summaryContent"></p>
		</div>
	</div>
</template>

<script setup lang="ts">
import { marked } from 'marked';
import { nextTick, ref, watch } from 'vue';
import { getErrorMessage, getSummaryContentAPI } from '@/api/index';

const props = withDefaults(
	defineProps<{
		lessonCode: string;
	}>(),
	{
		lessonCode: ''
	}
);

watch(
	() => props.lessonCode,
	(val) => {
		if (val) {
			nextTick(() => {
				getSummaryContent();
			});
		}
	},
	{ immediate: true }
);

// AI总结内容
const summaryContent = ref('暂无内容');

// 查询AI教学内容总结
const getSummaryContent = async () => {
	try {
		const data = await getSummaryContentAPI({
			businessCode: props.lessonCode
		});

		if (data) {
			const txt = await marked.parse(data);
			summaryContent.value = txt;
		} else {
			summaryContent.value = '暂无内容';
		}
	} catch (err) {
		console.error(getErrorMessage(err));
		summaryContent.value = '暂无内容';
	}
};
</script>

<style lang="scss" scoped>
.teaching-content-wrapper {
	.detail {
		line-height: $line-height-lg;
	}
}
</style>
